import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './static/style/variable.scss'
// 1.引入你需要的组件
import { Form, Rate, AddressEdit, ActionSheet, ImagePreview, Popup, PullRefresh, Toast, Cell, Card, Button, Swipe, SwipeItem, Tab, Tabs, Search, NavBar, TextEllipsis, Stepper, Field, CellGroup, SwipeCell } from 'vant';
import { showSuccessToast, showFailToast } from 'vant';

//2.引入组件样式
import 'vant/lib/index.css';

//3.路由守卫
router.beforeEach((to, from, next) => {
    let token = sessionStorage.getItem("auto_token1");

    if (to.name == 'menu' || to.name == 'order' || to.name == 'shopCar') {
        if (token != null) {
            next()
        } else {
            showFailToast("还没登录呢亲")
            next({
                name: 'login'
            })
        }
    } else {
        next()
    }
})


//vant组件
const app = createApp(App);
app.use(store)
app.use(router)
app.mount('#app')
//3. 注册你需要的组件
app.use(Button);
app.use(Swipe);
app.use(SwipeItem);
app.use(Tab);
app.use(Tabs);
app.use(Search);
app.use(NavBar);
app.use(TextEllipsis);
app.use(Field);
app.use(Cell);
app.use(CellGroup);
app.use(Stepper);
app.use(SwipeCell);
app.use(Card);
app.use(Form);
app.use(Toast);
app.use(PullRefresh);
app.use(ImagePreview);
app.use(Popup);
app.use(AddressEdit);
app.use(ActionSheet);
app.use(Rate);